home *** CD-ROM | disk | FTP | other *** search
- /* a HyperCard XFCN that closes the chosen text
- * file, given its file refNum as an input argument ... returns
- * 1 if successful, null string if failure....
- *
- * make it XFCN number 296 and call it "closeFile"
- *
- * 871127 ^z
- */
-
- #include <MacTypes.h>
- #include <OSUtil.h>
- #include <FileMgr.h>
- #include <HyperXCmd.h>
- #include <proto.h>
-
- pascal void main (XCmdBlockPtr paramPtr);
- void complain (XCmdBlockPtr paramPtr);
-
- pascal void main (paramPtr)
- XCmdBlockPtr paramPtr;
- {
- Handle answer;
- int refNum0;
-
- if (paramPtr->paramCount != 1)
- {
- complain (paramPtr);
- return;
- }
-
- refNum0 = atol (*(paramPtr->params[0]));
-
- if (FSClose (refNum0) != noErr)
- {
- complain (paramPtr);
- return;
- }
-
- answer = NewHandle (2);
- **answer = '1';
- *(*answer + 1) = '\0';
- paramPtr->returnValue = answer;
- return;
- }
-
-
-
- /* function to beep and set the return string to null (= "")
- */
-
- void complain (paramPtr)
- XCmdBlockPtr paramPtr;
- {
- Handle answer;
-
- SysBeep (10);
- answer = NewHandle (1);
- **answer = '\0';
- paramPtr->returnValue = answer;
- return;
- }
-
-
-
- /* function to convert alphabetic string to a long integer ... from LSC
- * library.... simplified to avoid using isspace() & isdigit() .... */
-
- long atol (s)
- register char *s;
- {
- register char signflag = 0;
- register long r = 0;
-
- while ((*s == ' '))
- s++;
-
- if (*s == '-')
- {
- signflag = 1;
- s++;
- }
- else if (*s == '+')
- s++;
-
- while (*s >= '0' && *s <= '9')
- r = r * 10 + (*s++ - '0');
-
- return (signflag ? -r : r);
- }
-
-